<style type="text/css">
<!--
.page_navi{width:100%;height:36px;line-height:36px;text-align:center;overflow:hidden;padding-top:1em;}
.page_navi a{padding:3px 8px;margin:2px;text-decoration:none;color:#888;border:1px solid #ccf;}
.page_navi a:hover,.page_navi a.current{border:1px solid #356aa0;color:#356aa0;font-weight:bolder;}
-->
</style>
<?php
function par_pagenavi($range = 9){
	global $paged, $wp_query;
	if ( !$max_page ) {$max_page = $wp_query->max_num_pages;}
	if($max_page > 1){if(!$paged){$paged = 1;}
	if($paged != 1){echo "<a href='" . get_pagenum_link(1) . "' class='extend' title='跳转到首页'> 返回首页 </a>";}
	previous_posts_link(' 上一页 ');
    if($max_page > $range){
		if($paged < $range){for($i = 1; $i <= ($range + 1); $i++){echo "<a href='" . get_pagenum_link($i) ."'";
		if($i==$paged)echo " class='current'";echo ">$i</a>";}}
    elseif($paged >= ($max_page - ceil(($range/2)))){
		for($i = $max_page - $range; $i <= $max_page; $i++){echo "<a href='" . get_pagenum_link($i) ."'";
		if($i==$paged)echo " class='current'";echo ">$i</a>";}}
	elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){
		for($i = ($paged - ceil($range/2)); $i <= ($paged + ceil(($range/2))); $i++){echo "<a href='" . get_pagenum_link($i) ."'";if($i==$paged) echo " class='current'";echo ">$i</a>";}}}
    else{for($i = 1; $i <= $max_page; $i++){echo "<a href='" . get_pagenum_link($i) ."'";
    if($i==$paged)echo " class='current'";echo ">$i</a>";}}
	next_posts_link(' 下一页 ');
    if($paged != $max_page){echo "<a href='" . get_pagenum_link($max_page) . "' class='extend' title='跳转到最后一页'> 最后一页 </a>";}}
}
?>
<?php
/**
 *
 * Template Name: Blog Index 
 *
 * This template is used to display all blog Items.
 *
 * @package Qualeb
 * @since Qualeb 1.0
 */

get_header(); 
?>
			<div id="header-description">
					<?php display_contact(); ?>
			</div><!-- #header-description -->
		</div><!-- #header-content -->
	</div><!-- #header -->

	<div id="content-blog" class="clearfix" role="main">
		<section id="primary">
			<div id="blogreg-index">		
					<?php 	
						$wp_query = new WP_Query();
						$wp_query->query( array( 'posts_per_page' => 3, 'paged' => $paged ) );
						$more = 0;
					?>
					<?php
						while ( $wp_query->have_posts() ) : $wp_query->the_post(); 
							get_template_part( 'content', 'blogreg' );
						endwhile;
					?>
				<?php if (  $wp_query->max_num_pages > 1 ) : ?>
				<div class="page_navi"><?php par_pagenavi(9); ?></div>
				<!-- #nav-below -->
				<?php endif; ?>
			</div><!-- #blogreg-index -->
		</section>	<!-- #primary -->
		<?php get_sidebar('blog'); ?>
	<?php get_footer(); ?>